package system;
import java.sql.*;
public class getTestGrade{
	int grade=0;
	
	public int getGrade(String studentid,String testid){		
		Connection con;
	    Statement sql;
	    ResultSet rs;
	    try{
	    	Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
	    	}
	    catch(Exception e){}
   
        try{
		String uri = "jdbc:sqlserver://127.0.0.1:1433;DatabaseName=test_system";
		String user = "sa";
		String password = "sa";
		con=DriverManager.getConnection(uri,user,password);
		sql=con.createStatement();
		rs=sql.executeQuery("select grade from student_test where student_id='"+studentid+"' and test_id='"+testid+"'");
		if(rs.next()){
			grade=rs.getInt(1);		
		}
		con.close();
	    } catch(SQLException e1){}
	    return grade;
	}
}